<template>
    <div class="page-100 service-provider-layout">
        <div v-for="(item,index) in providerList" @click="selectProviderItem(index)">
            <p class="title">{{item.name}}</p>
        </div>
    </div>
</template>

<script>
    import {showServiceProviderForUser} from "../../pcof/post";
    import {userInfoData,providerObject} from '../../globalVariables'
    export default {
        name: "serviceProvider",
        data() {
            return {
                providerList: '',
                selectItem: '',
            }
        },
        created() {
           this.showServiceProviderForUserFunc();
        },
        methods: {
            async showServiceProviderForUserFunc() {
                this.$dialog.loading.open('加载中...');
                var response = await showServiceProviderForUser(
                    JSON.parse(localStorage.getItem(userInfoData)).mobile
                );
                console.log(response.data.data);
                if (response.data.code === 200) {
                    this.$dialog.loading.close();
                    this.providerList = response.data.data;
                } else {
                    this.$dialog.loading.close();
                    this.$dialog.toast({
                        mes: response.data.msg,
                        icon: 'error',
                        timeout: 1500
                    });
                }
            },
            selectProviderItem(index) {
                this.selectItem = this.providerList[index];
                localStorage.setItem(providerObject,JSON.stringify(this.selectItem));
                this.$router.back();
            }
        }
    }
</script>

<style lang="scss">
    .service-provider-layout {

        .title{
            font-size: 0.25rem;
            color: #858585;
            text-align: left;
            height: 50px;
            padding-top: 20px;
            margin: 0 10px 0 20px;
            border-bottom:1px solid #e1e1e1;

        }
    }
</style>